<template>
	<view>
		<cu-custom :isBack="true" bgColor="bg-white">
			<block slot="backText"></block>
			<block slot="content"><text>收益明细</text></block>
		</cu-custom>

		<view class="relative margin">
			<image src="https://gsconline-1251028293.cos.ap-guangzhou.myqcloud.com/images/2020/05/19/image_158987198310297101.png"
			 mode="widthFix" class="w100"></image>
			<view class="absolute statistics_view">
				<view class="space-between margin-top-xl">
					<view class="margin-left">
						<view class="text-white ">当前余额</view>
						<view class="text-white text-xxxl  text-bold margin-top">{{member?member.account.user_money:'-'}}</view>
					</view>
					<view>
						<!-- <view class="cu-btn block bg-white btnr text-orange" @tap="goPage('/pages/member/recharge/index')">充值</view> -->
						<view class="cu-btn block bg-white btnr text-orange margin-top-sm" @tap="goPage('/pages/member/withdraw/apply')">提现</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bg-white radius margin-top margin-lr">
			<view class="cu-bar  margin-top">
				<view class="action text-bold text-black m-title">收益明细</view>
			</view>
			<view class="cu-list menu">
				<view class="cu-item arrow" @tap="goPage('/pages/income/list')">
					<view class="content">总收益</view>
					<view class="action text-orange">{{member?member.account.accumulate_money:''}}</view>
				</view>
				<view class="cu-item arrow" @tap="goPage('/pages/income/list2')">
					<view class="content">本金余额</view>
					<view class="action text-orange">{{member?member.account.frozen_money:''}}</view>
				</view>
				<view class="cu-item arrow" @tap="goPage('/pages/income/list2?t=frozen_money2')">
					<view class="content">金币</view>
					<view class="action text-orange">{{member?member.account.frozen_money2:''}}</view>
				</view>
				<view class="cu-item arrow" @tap="goPage('/pages/income/list3?t=wholesale_money')">
					<view class="content">中奖分红奖励</view>
					<view class="action text-orange">{{member?member.account.wholesale_money:''}}</view>
				</view>
				<!-- <view class="cu-item arrow" @tap="goPage('/pages/income/order')">
					<view class="content">进货记录</view>
					<view class="action text-orange">{{statistics?statistics.credits_order:''}}</view>
				</view> -->
			</view>
		</view>
		<view class="bg-white radius margin-top margin-lr">
			<view class="cu-bar  margin-top">
				<view class="action text-bold text-black m-title">积分明细</view>
			</view>
			<view class="cu-list menu">
				<view class="cu-item arrow" @tap="goPage('/pages/member/interval/index')">
					<view class="content">剩余</view>
					<view class="action text-orange">{{member?member.account.user_integral:''}}</view>
				</view>
				<!-- <view class="cu-item arrow" @tap="goPage('/pages/income/order')">
					<view class="content">进货记录</view>
					<view class="action text-orange">{{statistics?statistics.credits_order:''}}</view>
				</view> -->
			</view>
		</view>
		<!-- <view class="bg-white radius margin-top margin-lr">
			<view class="cu-bar  margin-top">
				<view class="action text-bold text-black m-title">提现</view>
			</view>
			<view class="cu-list menu">
				<view class="cu-item arrow" @tap="goPage('/pages/income/cash_list')">
					<view class="content">累计提现</view>
					<view class="action text-orange">{{statistics?statistics.withdraw_integral:''}}</view>
				</view>
			</view>
		</view> -->

	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		computed: mapState(['forcedLogin', 'hasLogin', 'channelLogin']),
		data() {
			return {
				statistics: null,
				member:null,
			}
		},
		onLoad() {
		},
		onShow() {
			if (this.$common.loginAuth(true)) {
				// this.$nextTick((r) => {
				// 	uni.startPullDownRefresh({})
				// })
				this.$common.getMember().then((member)=>{
					this.member = member
				})
			}
		},
		methods: {
			getInfo() {
				this.$http
					.get('integral_info', {})
					.then((response) => {
						this.statistics = response.data.data
						this.$common.setCache('credit_statictics', this.statistics, 10 * 60)
						uni.hideLoading()
						uni.stopPullDownRefresh()
					})
					.catch((response) => {
						console.log(response)
					})
			},
			tabSelect(index) {
				this.TabCur = index
				if (this.TabCur == 0) {
					this.getList()
				} else {
					this.getWithdrawLog()
				}
			},
			getWithdrawLog() {
				if (this.withdrawObj.hasMore) {
					this.withdrawObj.loading = true
					this.$http
						.get('withdraw_log', {
							page: this.withdrawObj.page
						})
						.then((response) => {
							let list = this.withdrawObj.list
							if (response.data.data.length > 0) {
								list = list.concat(response.data.data)
							} else {
								this.withdrawObj.hasMore = false
							}
							this.withdrawObj.list = list
							this.withdrawObj.loading = false
							this.withdrawObj.page += 1
							console.log(this.withdrawObj)
						})
						.catch((response) => {
							console.log(response)
						})
				}
			},
			getList() {
				if (this.creditObj.hasMore) {
					this.creditObj.loading = true
					this.$http
						.get('integral_details', {
							page: this.creditObj.page,
							type: this.creditObj.type
						})
						.then((response) => {
							let list = this.creditObj.list
							if (response.data.data.length > 0) {
								list = list.concat(response.data.data)
							} else {
								this.creditObj.hasMore = false
							}
							this.creditObj.list = list
							this.creditObj.loading = false
							this.creditObj.page += 1
						})
						.catch((response) => {
							console.log(response)
						})
				}
			},
			scrollForMore() {
				if (this.TabCur == 0) {
					this.getList()
				} else {
					this.getWithdrawLog()
				}
			},
			goCash: function(e) {
				uni.navigateTo({
					url: "../income/cash"
				})
			},
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal(e) {
				this.modalName = null
			},
			RadioChange(e) {
				this.creditObj = parseInt(e.detail.value)
				console.log(this.creditObj)
				this.modalName = null
				this.getList()
			},
		},
		onPullDownRefresh() {
			this.getInfo()
		},
	}
</script>

<style>
	.relative {
		position: relative;
	}

	.absolute {
		position: absolute;
	}

	.statistics_view {
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
	}

	.text-xxxl {
		font-size: 80rpx;
	}

	.btnr {
		border-radius: 40rpx 0 0 40rpx;
		padding: 0 40rpx 0 50rpx;
		height: 60rpx;
	}

	.m-title {
		font-size: 32rpx !important;
		position: relative;
		display: block;
	}

	.m-title::after {
		content: "";
		left: 0;
		position: absolute;
		width: 70rpx;
		height: 4rpx;
		bottom: 0;
		background-color: #ffb03a;
		z-index: 0;
	}
</style>
